//
//  WHZSportsHomeViewController.m
//  WHZGuDong
//
//  Created by whz on 16/11/8.
//  Copyright © 2016年 whz. All rights reserved.
//

#import "WHZSportsHomeViewController.h"
#import "WHZSportsHomeTracking.h"
#import "WHZSportingViewController.h"
#import <Masonry.h>

@interface WHZSportsHomeViewController ()

/**
 运动的米数
 */
@property(nonatomic, strong)UILabel *labelRunNum;
/**
 跑
 */
@property(nonatomic, strong)UIButton *buttonRun;
/**
 走
 */
@property(nonatomic, strong)UIButton *buttonWalk;
/**
 骑车
 */
@property(nonatomic, strong)UIButton *buttonBike;

@end



@implementation WHZSportsHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // MARK: - 初始化UI
    [self setupUI];
}

#pragma mark - 初始化UI
- (void)setupUI {
    
    // MARK: - 初始化控件
    // MARK: - 假数据
    self.labelRunNum = [[UILabel alloc] init];
    self.labelRunNum.text = @"我整了1000米";
    self.labelRunNum.textColor = [UIColor blackColor];
    self.labelRunNum.font = [UIFont systemFontOfSize:14];
    self.labelRunNum.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.labelRunNum];
    [self.labelRunNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.equalTo(self.view.mas_top).offset(100);
    }];
    
    // MARK: - 跑步按钮
    self.buttonRun = [[UIButton alloc] init];
    self.buttonRun.tag = 0;
    [self.buttonRun setTitle:@"Run" forState:UIControlStateNormal];
    [self.buttonRun setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    self.buttonRun.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.buttonRun];
    [self.buttonRun mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.labelRunNum.mas_centerX);
        make.bottom.equalTo(self.labelRunNum.mas_bottom).offset(100);
    }];
    [self.buttonRun addTarget:self action:@selector(buttonSportsClick:) forControlEvents:UIControlEventTouchUpInside];
    
    // MARK: - 走不按钮
    self.buttonWalk = [[UIButton alloc] init];
    self.buttonWalk.tag = 1;
    [self.buttonWalk setTitle:@"Walk" forState:UIControlStateNormal];
    [self.buttonWalk setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    self.buttonWalk.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.buttonWalk];
    [self.buttonWalk mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.buttonRun.mas_centerX);
        make.top.equalTo(self.buttonRun.mas_bottom).offset(10);
    }];
    [self.buttonWalk addTarget:self action:@selector(buttonSportsClick:) forControlEvents:UIControlEventTouchUpInside];
    
    // MARK: - 骑车按钮
    self.buttonBike = [[UIButton alloc] init];
    self.buttonBike.tag = 2;
    [self.buttonBike setTitle:@"Bike" forState:UIControlStateNormal];
    [self.buttonBike setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
    self.buttonBike.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.buttonBike];
    [self.buttonBike mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.buttonWalk.mas_centerX);
        make.top.equalTo(self.buttonWalk.mas_bottom).offset(10);
    }];
    [self.buttonBike addTarget:self action:@selector(buttonSportsClick:) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark - 按钮点击监听
- (void)buttonSportsClick:(UIButton *)sender {

    WHZSportsType type = sender.tag;
    
    WHZSportingViewController *vc = [WHZSportingViewController new];
    
    vc.sportType = type;
    
    [self presentViewController:vc animated:YES completion:nil];
}


@end
